<!-- 绿色通道 - 患者列表 - 医疗记录 - 急诊接诊 界面 -->
<template>
  <div class="info">
    <el-row type="flex" justify="end" style="padding-right: 40px">
      <el-button type="primary" @click="update">保存</el-button>
    </el-row>
    <el-form ref="patientForm" :model="patientForm" :rules="rules" label-width="200px" class="pageForm">
      <el-row class="form-row">
        <el-col :span="24">
          <h3 class="fl">120接诊</h3>
        </el-col>
        <el-col :span="24">
          <el-col :span="8">
            <el-form-item label="首次医疗接触时间" required>
              <el-date-picker
                v-model="patientForm.dispatchEmergens.firstMedicalContactDateTime"
                type="datetime"
                size="mini"
                value-format="yyyy-MM-dd HH:mm:ss"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="患者发生创伤时间">
              <el-date-picker
                v-model="patientForm.dispatchEmergens.arrivalTime"
                type="datetime"
                size="mini"
                value-format="yyyy-MM-dd HH:mm:ss" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="救护车">
              <el-input v-model="patientForm.dispatchEmergens.jiuhuche" size="mini" />
            </el-form-item>
          </el-col>
        </el-col>
        <el-col :span="24">
          <el-col :span="8">
            <el-form-item label="跟车医生">
              <el-input v-model="patientForm.dispatchEmergens.gencheyisheng" size="mini" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="跟车护士">
              <el-input v-model="patientForm.dispatchEmergens.genchehushi" size="mini" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发车时间">
              <el-date-picker
                v-model="patientForm.dispatchEmergens.facheshijian"
                type="datetime"
                size="mini"
                value-format="yyyy-MM-dd HH:mm:ss"
              />
            </el-form-item>
          </el-col>
        </el-col>
        <el-col :span="24">
          <el-col :span="8">
            <el-form-item label="到达现场时间">
              <el-date-picker
                v-model="patientForm.dispatchEmergens.daodaxianchangshijian"
                type="datetime"
                size="mini"
                value-format="yyyy-MM-dd HH:mm:ss"
              />
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="出发地点">
              <el-input v-model="patientForm.dispatchEmergens.chufadidian" size="mini" />
            </el-form-item>
          </el-col>
        </el-col>
      </el-row>
      <el-row class="form-row">
        <el-col :span="24">
          <h3 class="fl">院内接诊</h3>
        </el-col>
        <el-col :span="24">
          <el-col :span="8">
            <el-form-item label="到达急诊科时间" required>
              <el-date-picker
                v-model="patientForm.dispatchEmergens.daodajizhenkeshijian"
                type="datetime"
                size="mini"
                value-format="yyyy-MM-dd HH:mm:ss"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="到达急诊科是否死亡" required>
              <el-radio v-model="patientForm.dispatchEmergens.daodajizhenkeshifousiwang" label="1">是</el-radio>
              <el-radio v-model="patientForm.dispatchEmergens.daodajizhenkeshifousiwang" label="0">否</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="入院诊断" required>
              <el-input v-model="patientForm.dispatchEmergens.gencheyisheng" size="mini" />
            </el-form-item>
          </el-col>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import {
  selectRegionEx,
  getPatientStroke,
  savePatientInfo,
  getPatientsImg,
  getDepartmentList,
  savePatientImg
} from '@/api/green-channel/info'

export default {
  name: "emergencyTreatment",
  // 由主页面(父组件) 接收来的, 选择项的数据
  // eslint-disable-next-line vue/require-prop-types
  props: ['checkrowdata'], // 由主页面(父组件) 接收来的, 选择项的数据
  data() {
    return {
      patientForm: {
        dispatchEmergens: {}
      },
      rules: {}
    }
  },
  created() {
    this.getPatientInfo()
  },
  methods: {
    update() {
      let whether = true
      this.patientForm.isKnownAttackTime = this.patientForm.isKnownAttackTime ? this.patientForm.isKnownAttackTime : '0'
      this.patientForm.patientId = this.checkrowdata.patientId
      this.patientForm.dispatchId = this.checkrowdata.dispatchId
      if (!this.patientForm.dispatchEmergens.firstMedicalContactDateTime) {
        this.$message.warning('首次医疗接触时间必须填写!')
        whether = false
      } else if (!this.patientForm.incidentDateTime) {
        this.$message.warning('患者发病时间必须填写!')
        whether = false
      }
      if (whether) {
        savePatientInfo(this.patientForm).then((res) => {
          if (res.code === 0) {
            this.$message.success('保存成功')
            this.getPatientInfo()
          } else {
            this.$message.error('保存失败')
          }
        })
      }
    },
    getPatientInfo() {
      getPatientStroke(
        this.checkrowdata.patientId,
        this.checkrowdata.dispatchId
      ).then((res) => {
        console.log(res, 'res')
        if (res.data) {
          this.patientForm = res.data
          this.comingWayCode = res.data.comingWayCode
          this.patientForm.dispatchEmergens = this.patientForm.dispatchEmergens || {}
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
  .info {
    overflow-x: auto;
    min-height: 80vh;

    .equal-row-height {
      line-height: 36px;
    }

    .form-row {
      .equal-row-height {
        margin-left: 20px;
      }
    }

    .el-form-item {
      margin-bottom: 10px;
    }

    .in-hospital {
      .title {
        width: 128px;
        font-size: 14px;
        color: #606266;
        text-align: right;
        padding-right: 12px;
        line-height: 36px;
      }
    }

    .line {
      height: 1px;
      width: 100%;
      border-top: 1px dashed #dcdfe6;
      margin: 10px 0 9px 0;
    }

    .outerBox {
      position: relative;
    }

    .icon-style {
      position: absolute;
      top: 0px;
      right: 0px;
      z-index: 99;
      font-size: 20px;
      font-weight: 700;
    }

    .icon-style:hover {
      cursor: pointer;
    }
  }
</style>
<style lang="scss">
  .info {
    .el-form-item__label {
      font-weight: normal;
    }

    .not-accurate-minutes {
      .el-input__inner {
        width: 130px;
        min-width: unset;
      }
    }

    .short-text {
      .el-input__inner {
        width: 85px;
        min-width: unset;
      }
    }

    .el-input__inner {
      min-width: 220px;
    }

    .radio-div {
      min-width: 220px;
    }

    .long-text {
      .el-input__inner {
        min-width: 545px;
      }
    }
  }
</style>

<style scoped>
  .table-bordered {
    border: 1px solid #ddd;
  }

  .table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
  }

  th,
  td {
    padding: 5px;
    border: 1px solid #ddd;
  }

  th {
    width: 200px;
  }

  td {
    width: 500px;
  }

  .pageForm {
    padding: 0 30px;
  }
</style>
